package com.dm.wallpaper.library.items;

import com.dm.wallpaper.library.ResourceTable;
import com.dm.wallpaper.library.helpers.WallpaperHelper;
import com.dm.wallpaper.library.utils.SystemUtils;
import ohos.app.Context;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/*
 * Wallpaper Board
 *
 * Copyright (c) 2017 Dani Mahardhika
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class WallpaperProperty {

    private int mIcon;
    private String mTitle;
    private String mDesc;

    public int getIcon() {
        return mIcon;
    }

    public String getTitle() {
        return mTitle;
    }

    public String getDesc() {
        return mDesc;
    }

    public WallpaperProperty setIcon(int icon) {
        mIcon = icon;
        return this;
    }

    public WallpaperProperty setTitle(String title) {
        mTitle = title;
        return this;
    }

    public WallpaperProperty setDesc(String desc) {
        mDesc = desc;
        return this;
    }

    public static List<WallpaperProperty> getWallpaperProperties(Context context, Wallpaper wallpaper) {
        List<WallpaperProperty> properties = new ArrayList<>();


        properties.add(new WallpaperProperty()
                .setIcon(ResourceTable.Graphic_svg_toolbar_details_name)
                .setTitle(wallpaper.getName())
                .setDesc(SystemUtils.getString(context, ResourceTable.String_wallpaper_property_name) + wallpaper.getName()));

        properties.add(new WallpaperProperty()
                .setIcon(ResourceTable.Graphic_svg_toolbar_details_author)
                .setTitle(wallpaper.getAuthor())
                .setDesc(SystemUtils.getString(context, ResourceTable.String_wallpaper_property_author) + wallpaper.getAuthor()));

        if (wallpaper.getDimensions() != null) {
            String title = wallpaper.getDimensions().getWidth() + " x " + wallpaper.getDimensions().getHeight() + " pixels";
            properties.add(new WallpaperProperty()
                    .setIcon(ResourceTable.Graphic_svg_toolbar_details_dimensions)
                    .setTitle(title)
                    .setDesc(SystemUtils.getString(context, ResourceTable.String_wallpaper_property_dimensions) + title));
        }

        if (wallpaper.getMimeType() != null) {
            String title = WallpaperHelper.getFormat(wallpaper.getMimeType()).toUpperCase(Locale.getDefault());
            properties.add(new WallpaperProperty()
                    .setIcon(ResourceTable.Graphic_svg_toolbar_details_format)
                    .setTitle(title)
                    .setDesc(SystemUtils.getString(context, ResourceTable.String_wallpaper_property_format) + title));
        }

        if (wallpaper.getSize() != 0) {
            String title = WallpaperHelper.getSize(wallpaper.getSize());
            properties.add(new WallpaperProperty()
                    .setIcon(ResourceTable.Graphic_svg_toolbar_details_size)
                    .setTitle(title)
                    .setDesc(SystemUtils.getString(context, ResourceTable.String_wallpaper_property_size) + title));
        }
        return properties;
    }
}
